package WrittenTest;

import java.util.Scanner;

public class test31 {
    // DNA序列
    // 算法原理：滑动窗口
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        int n = in.nextInt();
        // 存储最后结果
        int endLeft = -1, endRight = -1, CG = 0;
        // 进窗口
        for (int left = 0, right = 0; right < str.length(); right++) {
            // 判断窗口是否合法
            while (right - left + 1 == n) {
                String s = str.substring(left, right + 1);
                int count = 0;
                // 判断子串是否合法
                for (int i = 0; i <= n - 3; i++) {
                    if (s.charAt(i) == 'C' && s.charAt(i + 1) == 'G') {
                        count++;
                        break;
                    }
                    if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C' && s.charAt(i + 2) == 'G') {
                        count++;
                        break;
                    }
                    if (s.charAt(i) == 'C' && s.charAt(i + 1) == 'G' && s.charAt(i + 2) == 'T') {
                        count++;
                        break;
                    }
                }
                if (count == 1) {
                    // 统计CG出现的次数
                    int tmp = 0;
                    for (int i = 0; i < n; i++) {
                        if (s.charAt(i) == 'C' || s.charAt(i) == 'G') {
                            tmp++;
                        }
                    }
                    // 跟新结果
                    if (tmp > CG) {
                        CG = tmp;
                        endLeft = left;
                        endRight = right;
                    }
                }
                // 出窗口
                left++;
            }
        }
        // 输出结果
        System.out.println(str.substring(endLeft, endRight + 1));
    }
}
